package com.zeekr.sdk.storage;

import android.content.Context;
import android.os.Environment;

import androidx.multidex.BuildConfig;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;

import com.zeekr.sdk.storage.core.StorageHandlerManager;
import com.zeekr.sdk.storage.encrypt.AESEncrypt;
import com.zeekr.sdk.storage.encrypt.EncryptConfig;
import com.zeekr.sdk.storage.process.MMKVProcessor;

/**
 * @author fqian
 * @date 2021/11/9
 */
public class StorageApplication extends MultiDexApplication {
    public static final String MAP_STYLE_NAME = "style2.data";

    public static final String MAP_STYLE_EXTRA_NAME = "style_extra2.data";
    @Override
    public void onCreate() {
        super.onCreate();
        try {
            if (ProcessUtils.isMainProcess(getApplicationContext())) {
                EncryptConfig.init("12345", false, false);
                StorageHandlerManager.registerCache("mmkv_storage", new MMKVProcessor(this, "mmkv_storage"), new AESEncrypt());
                StorageHandlerManager.registerCache("sp_storage", new MMKVProcessor(this, "sp_storage"), new AESEncrypt());
                StorageHandlerManager.registerCache("file_storage", new MMKVProcessor(this, "file_storage"), new AESEncrypt());
            }
        }catch (SecurityException e){
            e.printStackTrace();
        }
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        // you must install multiDex whatever tinker is installed!
        MultiDex.install(base);
    }
}
